	<h2><?php __('Applications');?></h2>
	<table id="list" cellpadding="0" cellspacing="0">
	<tr class="head">
			<th><?php echo $this->Paginator->sort('Applicant info','modified');?></th>
			<th colspan="2"><?php echo $this->Paginator->sort('Application Status','modified');?></th>
	</tr>
	<?php
	$i = 1;
	foreach ($applications as $app):
		$class = null;
		if ($i++ % 2)
			$class = ' class="odd"';
		else 
			$class = ' class="even"';
	?>
	<?php if (!($i+1)%6) { echo '<tr class="head"><th>Applicant info:</th><th colspan="2">Application Status:</th></tr>';} ?>
	<tr<?php echo $class;?>>
		<td>
			<strong>Name: </strong><?php echo $app['Application']['lastname'] 
							. ', ' . $app['Application']['firstname'] 
							. ' '. $app['Application']['middlename']; ?><br />
			<strong>Username: </strong><?php echo $app['User']['username'];?><br />
			<strong>Email: </strong><?php echo $app['User']['email'];?><br />
			<strong>Phone: </strong><?php echo $app['Application']['phone_pri'];?><br />
			<strong>Last Modified on: </strong><?php echo $app['Application']['modified'];?><br />
			<?php echo $this->Html->link('Modify Status Messages/ Edit Account', array(
																		'controller' => 'Applications',
																		'action' => 'modifyStatus',
																		$app['Application']['id']));
					  echo '<br />' . $this->Html->link('Delete User', array(
					  																		'controller' => 'Users',
					  																		'action' => 'delete',
					  																		$app['User']['id']), null,
					  																	'Are you sure you want to delete user '
					  													  			. $app['Application']['firstname'] 
					  													  			. ' ' . $app['Application']['lastname']);	
						echo '<br />' . $this->Html->link('Upload paper Recommendation', array(
																								'controller' => 'References',
																								'action' => 'adminComplete',
																								$app['Application']['id']));
						echo '<br />' . $this->Html->link('Add GRE and TOEFL scores', array(
																								'controller' => 'Scores',
																								'action' => 'edit',
																								$app['Score']['id']));
			?>
		</td>
		<td>
			<?php
				echo "<ul><li>" . renderStat($app['Application']['pif_stat'], $this->Html) 
							. ' <span>' . $this->Html->link('Personal Info', array(
																								'controller' => 'Applications',
																								'action' => 'edit',
																								$app['Application']['id']))
							. ' <br /> (' . $app['Application']['pif_mod']. ')</span></li>';
							
				echo "<li>" . renderStat($app['Application']['studyinterest_stat'], $this->Html) 
							. ' <span>' . $this->Html->link('Study/Research Interests', array(
																								'controller' => 'Studyinterests',
																								'action' => 'edit',
																								$app['Studyinterest']['id']))
							. ' <br /> ('. $app['Application']['studyinterest_mod']. ')</span></li>';
				
				echo "<li>" . renderStat($app['Application']['edhistory_stat'], $this->Html) 
							. ' <span>' . $this->Html->link('Educational History', array(
																								'controller' => 'Schools',
																								'action' => 'index',
																								$app['Application']['id']))
							. ' <br /> ('. $app['Application']['edhistory_mod']. ')</span></li>';
							
				echo "<li>" . renderStat($app['Application']['courses_stat'], $this->Html) 
							. ' <span>' . $this->Html->link('Courses', array(
																								'controller' => 'Courselists',
																								'action' => 'edit',
																								$app['Courselist']['id']))
							. '<br /> ('. $app['Application']['courses_mod']. ')</span></li>';
							
				echo "<li>" . renderStat($app['Application']['references_stat'], $this->Html) 
							. ' <span>' . $this->Html->link('References', array(
																								'controller' => 'References',
																								'action' => 'index',
																								$app['Application']['id']))
							. ' <br /> ('. $app['Application']['references_mod']. ')</span></li></ul>';
			?>
		</td>	
		<td>
			<?php
				echo "<ul><li>" . renderStat($app['Application']['depth_stat'], $this->Html) 
						 . ' <span>' . $this->Html->link('Additional Qualifications', array(
						 																	'controller' => 'Attachments',
						 																	'action' => 'add', 
						 																	$app['Application']['id'],
						 																	'cv'))
						 . ' <br /> ('. $app['Application']['depth_mod']. ')</span></li>';
						 
				echo "<li>" . renderStat($app['Application']['pstatement_stat'], $this->Html) 
							. ' <span>' . $this->Html->link('Personal Statement', array(
																								'controller' => 'Attachments',
																								'action' => 'add',
																								 $app['Application']['id'],
																								'ps')) 
							.' <br /> (' . $app['Application']['pstatement_mod']. ')</span></li>';
							
				echo "<li>" . renderStat($app['Application']['wsample_stat'], $this->Html) 
						 . ' <span>' . $this->Html->link('Writing Sample', array(
						 																 	 'controller' => 'Attachments',
						 																 	 'action' => 'add',
						 																 	  $app['Application']['id'],
						 																 	 'ws')) 
						 . ' <br /> ('. $app['Application']['wsample_mod']. ')</span></li>';
						 
				echo "<li>" . renderStat($app['Application']['transcripts_stat'], $this->Html) 
						 . ' <span>' . $this->Html->link('Transcripts Received', array(
						 																	'controller' => 'Applications',
						 																	'action' => 'transcripts',
						 																	$app['Application']['id'])) 
						 . ' <br /> ('. $app['Application']['transcripts_mod']. ')</span></li>';
						 
				echo "<li>" . renderStat($app['Application']['gre_stat'], $this->Html) 
						 . ' <span>' . $this->Html->link('GRE Scores Received', array( 
						 																	'controller' => 'Applications',
						 																	'action' => 'gre',
						 																	$app['Application']['id'])) 
						 . ' <br /> ('. $app['Application']['gre_mod']. ')</span></li>';
						 
				if ($app['Application']['toefl_req']) {
					echo "<li>" . renderStat($app['Application']['toefl_stat'], $this->Html) 
							 . ' <span>' . $this->Html->link('Toefl Scores', array(
							 																	'controller' => 'Applications',
							 																	'action' => 'toefl',
							 																	$app['Application']['id'])) 
							 . ' <br /> ('. $app['Application']['toefl_mod']. ')</span></li></ul>';
				} else {
					echo '</ul>';
				}
			?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>

<?php 

	function renderStat($status, $html) {
		switch ($status) {
			case 'red': 
				return $html->image('redlight_yb.jpg', array('alt' => 'No Submission'));
				break;
			case 'yellow':
				return $html->image('yellowlight_yb.jpg', array('alt' => 'Incomplete'));
				break;
			case 'green':
				return $html->image('greenlight_yb.jpg', array('alt' => 'Complete'));
				break;
		}
	}

?>